package com.earthquake.monitor_system.dao;

import com.earthquake.monitor_system.domain.SysMenuDomain;
import com.earthquake.monitor_system.domain.UserMenuDomain;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface SysMenuDao {
    @Select("select * from sys_menu where isNull(pid)")
    public List<SysMenuDomain> getParentMenu();
    @Select("select * from sys_menu where id=#{id}")
    public SysMenuDomain getSysMenu(Integer id);
    @Select("select * from sys_menu where pid=#{id}")
    public  List<SysMenuDomain>  getChildrenMenu(Integer id);
    @Insert("INSERT INTO sys_menu(name, path,icon,pagePath) VALUES (#{name},#{path},#{icon},#{pagePath});")
    public  Boolean  insetParentMenu(SysMenuDomain sysMenuDomain);
    @Insert("INSERT INTO sys_menu(name, path,pid,pagePath) VALUES (#{name},#{path},#{pid},#{pagePath});")
    public  Boolean  insetChildrenMenu(SysMenuDomain sysMenuDomain);
    @Select("select * from sys_menu where name=#{name} and isNull(pid)")
    public  SysMenuDomain  getOne(String name);
    @Select("select * from sys_menu where name=#{name} and isNull(icon)")
    public  SysMenuDomain  getChildrenOne(String name);
    @Update("UPDATE sys_menu SET name=#{name}, path=#{path},pagePath=#{pagePath},icon=#{icon} WHERE id=#{id}")
    public  Boolean  updateMenu(SysMenuDomain sysMenuDomain);
    @Delete("DELETE FROM sys_menu WHERE id=#{id};")
    public  Boolean  DeleteMenu(Integer id);
    public  Boolean  userMenu(Integer id, List menuList);
    @Delete("DELETE FROM user_menu WHERE user_id=#{userId};")
    public  Boolean  deleteUserMenu(Integer userId);
    @Select("SELECT * FROM user_menu WHERE user_id=#{userId};")
    public  List<UserMenuDomain> getUserMenu(Integer userId);
}
